package com.yzt;
import java.util.Scanner;
import java.util.Random;
public class RandomNum {
    public static void main (String[] args){
    getRandomNum();

    }
    public static void getRandomNum(){
        Random random = new Random();
       int num1 =  random.nextInt(100);
        System.out.println(num1);
        while (true){
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入一个数");
            int num2 = sc.nextInt();
            System.out.println("你输入的数是" + num2);
            if (num1 == num2){
                System.out.println("恭喜你猜对了，数字是：" + num1);
                break;
            }else if (num2 > num1) {
                System.out.println("猜大了，换一个小的数猜吧");
            }else {
                System.out.println("猜小了，换一个大的数猜吧");
            }

        }


    }
}
